import { getDB } from "../utils/db/mysql";
export default defineEventHandler(async (event) => {
  console.log("事件", event);
  let con = getDB();
  let body = await readBody(event)
  console.log(body, 'login');
  let { username, password, } = body
  let [data] = await con.query("select * from userinfo where username =?", [username]);
  if (data.length > 0) {
    return {
      code: 4001,
    }
  }else{
    let [result] = await con.query("INSERT into userinfo(username,password) VALUES(?,?)", [username,password]);
    return{
        code:2000
    }
  }
});
